home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 599 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: EU.net!sun4nl!xs4all!marketgraph!rvg
  2. From: rvg@marketgraph.xs4all.nl (Ruud van Gaal)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: LoadRGB32()
  5. Message-ID: <360flah60.alamito@marketgraph.xs4all.nl>
  6. Date: Mon, 8 Jan 96 11:15:54 CET
  7. References: <4cguvt$aa2@serveur.cribx1.u-bordeaux.fr>
  8. Reply-To: rvg@marketgraph.xs4all.nl
  9. X-Newsreader: Alamito Mail and News Manager (V2.0.4 for Waffle) registered to MARKETGRAPH VISUAL AUTOMATION
  10.  
  11. In <4cguvt$aa2@serveur.cribx1.u-bordeaux.fr> 
  12. skoruppa@athena.ceremab.u-bordeaux.fr (Nils Skoruppa) wrote:
  13.  
  14. >So I changed the program to use  LoadRGB32()
  15. >instead of  LoadRGB4() (and ULONGs and so forth).
  16. >Unfortunately, now AGA IFF-ILBM files are no longer
  17. >loaded correctly, garbage is displayed instead
  18. >(not only wrong colours, but a completely wrong
  19. >bitmap). On the other hand, I did not at all touch the
  20. >routine which (finds and) decodes the BODY to a BitMap.
  21.  
  22. LoadRGB32() doesn't work AT ALL like LoadRGB4() does (it really works very 
  23. strange, and you would probably NEVER find the solution by hand). Here's an 
  24. extract from a ViewPort wrapper function I use daily in my programs (i.e. 
  25. it's tested). It's C++, but you'll get the idea.
  26.  
  27. void QViewPort::SetPalette(QPalette *qpal)
  28. /** Set palette from QPalette **/
  29. { ulong ctable[256*3+2];    // System needs longs; stacksize!
  30.   ubyte *sct;               // Source ct
  31.   ulong c;
  32.   /** Create ULONG table for faster LoadRGB32() **/
  33.   sct=(ubyte*)qpal->CT24();
  34.   ctable[0]=(((ulong)qpal->Colors())<<16);  // Upper word=count, lwr=offset 
  35. into colormap
  36.   for(int i=0;i<qpal->Colors();i++)
  37.   { c=(ulong)sct[i*3+0]; c=(c<<24)|(c<<16)|(c<<8)|c;
  38.     ctable[i*3+1]=c;
  39.     c=(ulong)sct[i*3+1]; c=(c<<24)|(c<<16)|(c<<8)|c;
  40.     ctable[i*3+2]=c;
  41.     c=(ulong)sct[i*3+2]; c=(c<<24)|(c<<16)|(c<<8)|c;
  42.     ctable[i*3+3]=c;
  43.   }
  44.   ctable[i*3+1]=0;              // Close table
  45.   LoadRGB32(vp,ctable);
  46. }
  47.  
  48. Yes, note the strange copying of the color values; It is actually a 96-bit 
  49. color value you're using.
  50. Don't know why they did this, but I had to ask this to another Amiga 
  51. programmer, since I too didn't have the autodocs. I hope AT gets its Web page 
  52. up real soon.
  53. Note that I use offset 0 in the above example.
  54.  
  55. --
  56. Ruud van Gaal
  57. MarketGraph Visual Automation
  58. E-Mail: rvg@marketgraph.xs4all.nl
  59. "...Works fascinates me. I could sit and watch it for hours..."
  60.  
  61.